package model;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Formatacoes {
	public static String dataAtual() {
		Date data = new Date(System.currentTimeMillis());
		SimpleDateFormat formatarDate = new SimpleDateFormat("yyyy-MM-dd");
		String dataAtual = formatarDate.format(data);
		System.out.println(dataAtual);
		return dataAtual;
	}

	public static String formatarDataInv(String data) {
		if (data.contains("-")) {
			int ano = Integer.parseInt(data.substring(0, 4));
			int mes = Integer.parseInt(data.substring(3, 5));
			int dia = Integer.parseInt(data.substring(6, 8));
			data = ano + "-" + mes + "-" + dia;
			System.out.println("com ----");
		} else {
			int dia = Integer.parseInt(data.substring(0, 2));
			int mes = Integer.parseInt(data.substring(3, 5));
			int ano = Integer.parseInt(data.substring(6, 10));
			data = ano + "-" + mes + "-" + dia;
			System.out.println("com /////");
		}
		return data;
	}

	public static String formatarDataAtual() {
		Date data = new Date(System.currentTimeMillis());
		SimpleDateFormat formatarDate = new SimpleDateFormat("dd-MM-yyyy");
		String dataAtual = formatarDate.format(data);
		String dataA = dataAtual.replace('/', '-');
		String dataInv = "";
		dataInv = "" + dataA.substring(6, 10) + dataA.substring(2, 6)
				+ dataA.substring(0, 2);
		return dataInv;
	}

	public static String formatarDataString(String data) {
		String dataA = data.replace('-', '/');
		String dataInv = "";
		dataInv = dataA.substring(8, 10) + "/" + dataA.substring(5, 7) + "/"
				+ dataA.substring(0, 4);
		return dataInv;
	}

}
